package leetcodecompetition.S109;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @Author: Siantar
 * @Date: 2023-07-22-22:44
 * @Description: 1.0
 */
public class T6926 {
    Set<Character> set = new HashSet<Character>(){{add('a');add('e');add('i');add('o');add('u');add('A');add('E');add('I');add('O');add('U');}};

    public String sortVowels(String s) {
        char[] cs = s.toCharArray();
        List<Integer> list1 = new ArrayList<>();
        List<Character> list2 = new ArrayList<>();
        int n = cs.length;
        for (int i = 0; i < n; i++) {
            if (set.contains(cs[i])){
                list1.add(i);
                list2.add(cs[i]);
            }
        }
        list2.sort((a, b) -> a - b);
        int size = list1.size();
        for (int i = 0; i < size; i++) {
            cs[list1.get(i)] = list2.get(i);
        }
        return new String(cs);
    }

    @Test
    public void test() {
        System.out.println(sortVowels("lEetcOde"));
    }
}
